import psutil
import datetime
cpu_counts=psutil.cpu_count()
cpu_times=psutil.cpu_times()
cpu_percent=psutil.cpu_percent(1)#percpu=True
cpu_memory=psutil.virtual_memory()
memory_percent=cpu_memory.percent
all_memory=cpu_memory.total/1024/1024/1024
left_memory=cpu_memory.free/1024/1024/1024
boot_time=psutil.boot_time()
boot_time_obj = datetime.datetime.fromtimestamp(boot_time)
now_time = datetime.datetime.now()
delta_time1 = now_time - boot_time_obj
print('开机时间:',boot_time_obj)
# print('当前时间:',str(now_time).split('.')[0])
print('开机时长:',str(delta_time1).split('.')[0])


print('cpu_counts:',cpu_counts)
print('cpu_times:',cpu_times)
print('cpu_percent:',cpu_percent)
print('cpu_memory:',cpu_memory)
print('memory_percent:',memory_percent)
print('all_memory:',all_memory)
print('left_memory:',left_memory)
# print('boot_day:',time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(boot_time)))